import React, { useEffect } from 'react';
import './index.less';
import { ConfigProvider } from 'antd'
import zhCN from 'antd/es/locale/zh_CN'
import { Routes, Route, HashRouter } from 'react-router-dom'
import Layout from '@/component/layout';
import LoginPage from '@/pages/login'
import NotFound from '@/pages/404'
import NotNetwork from '@/pages/notNetwork'
import { useDispatch } from 'react-redux'
import { handlingDialogs, IConfirmDialog } from '@/store/models/app'

function App() {
  const dispatch = useDispatch()
  useEffect(() => {
    window.ConfirmDialog = function (obj: IConfirmDialog) {
      dispatch(
        handlingDialogs({
          ...obj,
          visible: true
        })
      )
    }
  }, [])

  return (
    <ConfigProvider locale={zhCN} theme={{
      token: {
        colorPrimary: '#00B7BF',
      },
    }}>
      <HashRouter>
        <Routes>
          <Route path={'/*'} element={<Layout />} />
          <Route path={'/login'} element={<LoginPage />} />
          <Route path={'/404'} element={<NotFound />} />
          <Route path={'/notNetwork'} element={<NotNetwork />} />
        </Routes>
      </HashRouter>
    </ConfigProvider>

  );
}

export default App;
